package com.nuaa.ange.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.nuaa.ange.annotation.ApiLog;
import com.nuaa.ange.common.lang.RespBean;
import com.nuaa.ange.entity.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description
 * @author 玦离
 * @date 2022/12/31 20:26
 */

@RestController
@Api(tags = "文章图片相关接口")
@RequestMapping("/article-pic")
public class ArticlePicController extends BaseController{

    @ApiOperation(value = "文章所有图片")
    @GetMapping("/get")
    @ApiLog
    public List<ArticlePic> getAllPicByAid(@RequestParam("articleId") int articleId) {
        return articlePicService.list(new QueryWrapper<ArticlePic>()
                .eq("article_id", articleId));
    }

    @ApiOperation(value = "删除文章图片")
    @GetMapping("/delete")
    @ApiLog
    public RespBean deletePic(@RequestParam("articleId") int articleId) {
        articlePicService.remove(new QueryWrapper<ArticlePic>()
                .eq("article_id", articleId));
        return RespBean.ok("删除图片成功");
    }
}



